package org.person.gift.clients.fallbackFactory;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.person.gift.clients.AuthClient;
import org.person.gift.domain.LoginUser;
import org.person.gift.util.AjaxResult;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class AuthClientFallback implements FallbackFactory<AuthClient> {
    @Override
    public AuthClient create(Throwable throwable) {
        log.error(throwable.getMessage());
        System.out.println(throwable.getMessage());
        return new AuthClient() {
            @Override
            public AjaxResult save(LoginUser loginUser) {
                return AjaxResult.me().setSuccess(false).setMessage("网络异常请稍后再试");
            }
        };
    }
}
